<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="curses-window-objects.html" />
<link rel="prev" href="module-curses.html" />
<link rel="parent" href="module-curses.html" />
<link rel="next" href="curses-window-objects.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>14.7.1 Functions </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="14.7 curses  "
  href="module-curses.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="14.7 curses  "
  href="module-curses.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="14.7.2 window Objects"
  href="curses-window-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-curses.html">14.7 curses  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-curses.html">14.7 curses  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="curses-window-objects.html">14.7.2 Window Objects</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION0016710000000000000000"></a><a name="curses-functions"></a>
<br>
14.7.1 Functions 
</h2>

<p>
The module <tt class="module">curses</tt> defines the following exception:

<p>
<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-2974' xml:id='l2h-2974' class="exception">error</tt></b></dt>
<dd>
Exception raised when a curses library function returns an error.
</dd></dl>

<p>
<span class="note"><b class="label">Note:</b>
Whenever <var>x</var> or <var>y</var> arguments to a function
or a method are optional, they default to the current cursor location.
Whenever <var>attr</var> is optional, it defaults to <tt class="constant">A_NORMAL</tt>.</span>

<p>
The module <tt class="module">curses</tt> defines the following functions:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2975' xml:id='l2h-2975' class="function">baudrate</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns the output speed of the terminal in bits per second.  On
software terminal emulators it will have a fixed high value.
Included for historical reasons; in former times, it was used to 
write output loops for time delays and occasionally to change
interfaces depending on the line speed.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2976' xml:id='l2h-2976' class="function">beep</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Emit a short attention sound.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2977' xml:id='l2h-2977' class="function">can_change_color</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns true or false, depending on whether the programmer can change
the colors displayed by the terminal.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2978' xml:id='l2h-2978' class="function">cbreak</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Enter cbreak mode.  In cbreak mode (sometimes called ``rare'' mode)
normal tty line buffering is turned off and characters are available
to be read one by one.  However, unlike raw mode, special characters
(interrupt, quit, suspend, and flow control) retain their effects on
the tty driver and calling program.  Calling first <tt class="function">raw()</tt>
then <tt class="function">cbreak()</tt> leaves the terminal in cbreak mode.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2979' xml:id='l2h-2979' class="function">color_content</tt></b>(</nobr></td>
  <td><var>color_number</var>)</td></tr></table></dt>
<dd>
Returns the intensity of the red, green, and blue (RGB) components in
the color <var>color_number</var>, which must be between <code>0</code> and
<tt class="constant">COLORS</tt>.  A 3-tuple is returned, containing the R,G,B values
for the given color, which will be between <code>0</code> (no component) and
<code>1000</code> (maximum amount of component).
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2980' xml:id='l2h-2980' class="function">color_pair</tt></b>(</nobr></td>
  <td><var>color_number</var>)</td></tr></table></dt>
<dd>
Returns the attribute value for displaying text in the specified
color.  This attribute value can be combined with
<tt class="constant">A_STANDOUT</tt>, <tt class="constant">A_REVERSE</tt>, and the other
<tt class="constant">A_*</tt> attributes.  <tt class="function">pair_number()</tt> is the
counterpart to this function.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2981' xml:id='l2h-2981' class="function">curs_set</tt></b>(</nobr></td>
  <td><var>visibility</var>)</td></tr></table></dt>
<dd>
Sets the cursor state.  <var>visibility</var> can be set to 0, 1, or 2, for
invisible, normal, or very visible.  If the terminal supports the
visibility requested, the previous cursor state is returned;
otherwise, an exception is raised.  On many terminals, the ``visible''
mode is an underline cursor and the ``very visible'' mode is a block cursor.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2982' xml:id='l2h-2982' class="function">def_prog_mode</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Saves the current terminal mode as the ``program'' mode, the mode when
the running program is using curses.  (Its counterpart is the
``shell'' mode, for when the program is not in curses.)  Subsequent calls
to <tt class="function">reset_prog_mode()</tt> will restore this mode.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2983' xml:id='l2h-2983' class="function">def_shell_mode</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Saves the current terminal mode as the ``shell'' mode, the mode when
the running program is not using curses.  (Its counterpart is the
``program'' mode, when the program is using curses capabilities.)
Subsequent calls
to <tt class="function">reset_shell_mode()</tt> will restore this mode.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2984' xml:id='l2h-2984' class="function">delay_output</tt></b>(</nobr></td>
  <td><var>ms</var>)</td></tr></table></dt>
<dd>
Inserts an <var>ms</var> millisecond pause in output.  
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2985' xml:id='l2h-2985' class="function">doupdate</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Update the physical screen.  The curses library keeps two data
structures, one representing the current physical screen contents
and a virtual screen representing the desired next state.  The
<tt class="function">doupdate()</tt> ground updates the physical screen to match the
virtual screen.

<p>
The virtual screen may be updated by a <tt class="method">noutrefresh()</tt> call
after write operations such as <tt class="method">addstr()</tt> have been performed
on a window.  The normal <tt class="method">refresh()</tt> call is simply
<tt class="method">noutrefresh()</tt> followed by <tt class="function">doupdate()</tt>; if you have
to update multiple windows, you can speed performance and perhaps
reduce screen flicker by issuing <tt class="method">noutrefresh()</tt> calls on
all windows, followed by a single <tt class="function">doupdate()</tt>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2986' xml:id='l2h-2986' class="function">echo</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Enter echo mode.  In echo mode, each character input is echoed to the
screen as it is entered.  
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2987' xml:id='l2h-2987' class="function">endwin</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
De-initialize the library, and return terminal to normal status.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2988' xml:id='l2h-2988' class="function">erasechar</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns the user's current erase character.  Under <span class="Unix">Unix</span> operating
systems this is a property of the controlling tty of the curses
program, and is not set by the curses library itself.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2989' xml:id='l2h-2989' class="function">filter</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
The <tt class="function">filter()</tt> routine, if used, must be called before
<tt class="function">initscr()</tt> is  called.  The effect is that, during those
calls, LINES is set to 1; the capabilities clear, cup, cud, cud1,
cuu1, cuu, vpa are disabled; and the home string is set to the value of cr.
The effect is that the cursor is confined to the current line, and so
are screen updates.  This may be used for enabling character-at-a-time 
line editing without touching the rest of the screen.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2990' xml:id='l2h-2990' class="function">flash</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Flash the screen.  That is, change it to reverse-video and then change
it back in a short interval.  Some people prefer such as `visible bell'
to the audible attention signal produced by <tt class="function">beep()</tt>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2991' xml:id='l2h-2991' class="function">flushinp</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Flush all input buffers.  This throws away any  typeahead  that  has
been typed by the user and has not yet been processed by the program.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2992' xml:id='l2h-2992' class="function">getmouse</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
After <tt class="method">getch()</tt> returns <tt class="constant">KEY_MOUSE</tt> to signal a mouse
event, this method should be call to retrieve the queued mouse event,
represented as a 5-tuple
<code>(<var>id</var>, <var>x</var>, <var>y</var>, <var>z</var>, <var>bstate</var>)</code>.
<var>id</var> is an ID value used to distinguish multiple devices,
and <var>x</var>, <var>y</var>, <var>z</var> are the event's coordinates.  (<var>z</var>
is currently unused.).  <var>bstate</var> is an integer value whose bits
will be set to indicate the type of event, and will be the bitwise OR
of one or more of the following constants, where <var>n</var> is the button
number from 1 to 4:
<tt class="constant">BUTTON<var>n</var>_PRESSED</tt>,
<tt class="constant">BUTTON<var>n</var>_RELEASED</tt>,
<tt class="constant">BUTTON<var>n</var>_CLICKED</tt>,
<tt class="constant">BUTTON<var>n</var>_DOUBLE_CLICKED</tt>,
<tt class="constant">BUTTON<var>n</var>_TRIPLE_CLICKED</tt>,
<tt class="constant">BUTTON_SHIFT</tt>,
<tt class="constant">BUTTON_CTRL</tt>,
<tt class="constant">BUTTON_ALT</tt>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2993' xml:id='l2h-2993' class="function">getsyx</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns the current coordinates of the virtual screen cursor in y and
x.  If leaveok is currently true, then -1,-1 is returned.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2994' xml:id='l2h-2994' class="function">getwin</tt></b>(</nobr></td>
  <td><var>file</var>)</td></tr></table></dt>
<dd>
Reads window related data stored in the file by an earlier
<tt class="function">putwin()</tt> call.  The routine then creates and initializes a
new window using that data, returning the new window object.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2995' xml:id='l2h-2995' class="function">has_colors</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns true if the terminal can display colors; otherwise, it
returns false. 
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2996' xml:id='l2h-2996' class="function">has_ic</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns true if the terminal has insert- and delete- character
capabilities.  This function is included for historical reasons only,
as all modern software terminal emulators have such capabilities.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2997' xml:id='l2h-2997' class="function">has_il</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns true if the terminal has insert- and
delete-line  capabilities,  or  can  simulate  them  using
scrolling regions. This function is included for historical reasons only,
as all modern software terminal emulators have such capabilities.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2998' xml:id='l2h-2998' class="function">has_key</tt></b>(</nobr></td>
  <td><var>ch</var>)</td></tr></table></dt>
<dd>
Takes a key value <var>ch</var>, and returns true if the current terminal
type recognizes a key with that value.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2999' xml:id='l2h-2999' class="function">halfdelay</tt></b>(</nobr></td>
  <td><var>tenths</var>)</td></tr></table></dt>
<dd>
Used for half-delay mode, which is similar to cbreak mode in that
characters typed by the user are immediately available to the program.
However, after blocking for <var>tenths</var> tenths of seconds, an
exception is raised if nothing has been typed.  The value of
<var>tenths</var> must be a number between 1 and 255.  Use
<tt class="function">nocbreak()</tt> to leave half-delay mode.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3000' xml:id='l2h-3000' class="function">init_color</tt></b>(</nobr></td>
  <td><var>color_number, r, g, b</var>)</td></tr></table></dt>
<dd>
Changes the definition of a color, taking the number of the color to
be changed followed by three RGB values (for the amounts of red,
green, and blue components).  The value of <var>color_number</var> must be
between <code>0</code> and <tt class="constant">COLORS</tt>.  Each of <var>r</var>, <var>g</var>,
<var>b</var>, must be a value between <code>0</code> and <code>1000</code>.  When
<tt class="function">init_color()</tt> is used, all occurrences of that color on the
screen immediately change to the new definition.  This function is a
no-op on most terminals; it is active only if
<tt class="function">can_change_color()</tt> returns <code>1</code>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3001' xml:id='l2h-3001' class="function">init_pair</tt></b>(</nobr></td>
  <td><var>pair_number, fg, bg</var>)</td></tr></table></dt>
<dd>
Changes the definition of a color-pair.  It takes three arguments: the
number of the color-pair to be changed, the foreground color number,
and the background color number.  The value of <var>pair_number</var> must
be between <code>1</code> and <code>COLOR_PAIRS - 1</code> (the <code>0</code> color
pair is wired to white on black and cannot be changed).  The value of
<var>fg</var> and <var>bg</var> arguments must be between <code>0</code> and
<tt class="constant">COLORS</tt>.  If the color-pair was previously initialized, the
screen is refreshed and all occurrences of that color-pair are changed
to the new definition.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3002' xml:id='l2h-3002' class="function">initscr</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Initialize the library. Returns a <tt class="class">WindowObject</tt> which represents
the whole screen.  <span class="note"><b class="label">Note:</b>
If there is an error opening the terminal,
the underlying curses library may cause the interpreter to exit.</span>
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3003' xml:id='l2h-3003' class="function">isendwin</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns true if <tt class="function">endwin()</tt> has been called (that is, the 
curses library has been deinitialized).
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3004' xml:id='l2h-3004' class="function">keyname</tt></b>(</nobr></td>
  <td><var>k</var>)</td></tr></table></dt>
<dd>
Return the name of the key numbered <var>k</var>.  The name of a key
generating printable ASCII character is the key's character.  The name
of a control-key combination is a two-character string consisting of a
caret followed by the corresponding printable ASCII character.  The
name of an alt-key combination (128-255) is a string consisting of the
prefix `M-' followed by the name of the corresponding ASCII character.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3005' xml:id='l2h-3005' class="function">killchar</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns the user's current line kill character. Under <span class="Unix">Unix</span> operating
systems this is a property of the controlling tty of the curses
program, and is not set by the curses library itself.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3006' xml:id='l2h-3006' class="function">longname</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns a string containing the terminfo long name field describing the current
terminal.  The maximum length of a verbose description is 128
characters.  It is defined only after the call to
<tt class="function">initscr()</tt>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3007' xml:id='l2h-3007' class="function">meta</tt></b>(</nobr></td>
  <td><var>yes</var>)</td></tr></table></dt>
<dd>
If <var>yes</var> is 1, allow 8-bit characters to be input. If <var>yes</var> is 0, 
allow only 7-bit chars.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3008' xml:id='l2h-3008' class="function">mouseinterval</tt></b>(</nobr></td>
  <td><var>interval</var>)</td></tr></table></dt>
<dd>
Sets the maximum time in milliseconds that can elapse between press and
release events in order for them to be recognized as a click, and
returns the previous interval value.  The default value is 200 msec,
or one fifth of a second.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3009' xml:id='l2h-3009' class="function">mousemask</tt></b>(</nobr></td>
  <td><var>mousemask</var>)</td></tr></table></dt>
<dd>
Sets the mouse events to be reported, and returns a tuple
<code>(<var>availmask</var>, <var>oldmask</var>)</code>.  
<var>availmask</var> indicates which of the
specified mouse events can be reported; on complete failure it returns
0.  <var>oldmask</var> is the previous value of the given window's mouse
event mask.  If this function is never called, no mouse events are
ever reported.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3010' xml:id='l2h-3010' class="function">napms</tt></b>(</nobr></td>
  <td><var>ms</var>)</td></tr></table></dt>
<dd>
Sleep for <var>ms</var> milliseconds.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3011' xml:id='l2h-3011' class="function">newpad</tt></b>(</nobr></td>
  <td><var>nlines, ncols</var>)</td></tr></table></dt>
<dd>
Creates and returns a pointer to a new pad data structure with the
given number of lines and columns.  A pad is returned as a
window object.

<p>
A pad is like a window, except that it is not restricted by the screen
size, and is not necessarily associated with a particular part of the
screen.  Pads can be used when a large window is needed, and only a
part of the window will be on the screen at one time.  Automatic
refreshes of pads (such as from scrolling or echoing of input) do not
occur.  The <tt class="method">refresh()</tt> and <tt class="method">noutrefresh()</tt> methods of a
pad require 6 arguments to specify the part of the pad to be
displayed and the location on the screen to be used for the display.
The arguments are pminrow, pmincol, sminrow, smincol, smaxrow,
smaxcol; the p arguments refer to the upper left corner of the pad
region to be displayed and the s arguments define a clipping box on
the screen within which the pad region is to be displayed.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3012' xml:id='l2h-3012' class="function">newwin</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>nlines, ncols,</var><big>]</big><var> begin_y, begin_x</var>)</td></tr></table></dt>
<dd>
Return a new window, whose left-upper corner is at 
<code>(<var>begin_y</var>, <var>begin_x</var>)</code>, and whose height/width is 
<var>nlines</var>/<var>ncols</var>.  

<p>
By default, the window will extend from the 
specified position to the lower right corner of the screen.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3013' xml:id='l2h-3013' class="function">nl</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Enter newline mode.  This mode translates the return key into newline
on input, and translates newline into return and line-feed on output.
Newline mode is initially on.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3014' xml:id='l2h-3014' class="function">nocbreak</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Leave cbreak mode.  Return to normal ``cooked'' mode with line buffering.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3015' xml:id='l2h-3015' class="function">noecho</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Leave echo mode.  Echoing of input characters is turned off.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3016' xml:id='l2h-3016' class="function">nonl</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Leave newline mode.  Disable translation of return into newline on
input, and disable low-level translation of newline into
newline/return on output (but this does not change the behavior of
<code>addch('\n')</code>, which always does the equivalent of return and
line feed on the virtual screen).  With translation off, curses can
sometimes speed up vertical motion a little; also, it will be able to
detect the return key on input.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3017' xml:id='l2h-3017' class="function">noqiflush</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
When the noqiflush routine is used, normal flush of input and
output queues associated with the INTR, QUIT and SUSP
characters will not be done.  You may want to call
<tt class="function">noqiflush()</tt> in a signal handler if you want output
to continue as though the interrupt had not occurred, after the
handler exits.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3018' xml:id='l2h-3018' class="function">noraw</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Leave raw mode. Return to normal ``cooked'' mode with line buffering.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3019' xml:id='l2h-3019' class="function">pair_content</tt></b>(</nobr></td>
  <td><var>pair_number</var>)</td></tr></table></dt>
<dd>
Returns a tuple <code>(<var>fg</var>, <var>bg</var>)</code> containing the colors for
the requested color pair.  The value of <var>pair_number</var> must be
between <code>1</code> and <code><tt class="constant">COLOR_PAIRS</tt> - 1</code>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3020' xml:id='l2h-3020' class="function">pair_number</tt></b>(</nobr></td>
  <td><var>attr</var>)</td></tr></table></dt>
<dd>
Returns the number of the color-pair set by the attribute value
<var>attr</var>.  <tt class="function">color_pair()</tt> is the counterpart to this
function.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3021' xml:id='l2h-3021' class="function">putp</tt></b>(</nobr></td>
  <td><var>string</var>)</td></tr></table></dt>
<dd>
Equivalent to <code>tputs(str, 1, putchar)</code>; emits the value of a
specified terminfo capability for the current terminal.  Note that the
output of putp always goes to standard output.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3022' xml:id='l2h-3022' class="function">qiflush</tt></b>(</nobr></td>
  <td><var> </var><big>[</big><var>flag</var><big>]</big><var> </var>)</td></tr></table></dt>
<dd>
If <var>flag</var> is false, the effect is the same as calling
<tt class="function">noqiflush()</tt>. If <var>flag</var> is true, or no argument is
provided, the queues will be flushed when these control characters are
read.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3023' xml:id='l2h-3023' class="function">raw</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Enter raw mode.  In raw mode, normal line buffering and 
processing of interrupt, quit, suspend, and flow control keys are
turned off; characters are presented to curses input functions one
by one.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3024' xml:id='l2h-3024' class="function">reset_prog_mode</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Restores the  terminal  to ``program'' mode, as previously saved 
by <tt class="function">def_prog_mode()</tt>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3025' xml:id='l2h-3025' class="function">reset_shell_mode</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Restores the  terminal  to ``shell'' mode, as previously saved 
by <tt class="function">def_shell_mode()</tt>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3026' xml:id='l2h-3026' class="function">setsyx</tt></b>(</nobr></td>
  <td><var>y, x</var>)</td></tr></table></dt>
<dd>
Sets the virtual screen cursor to <var>y</var>, <var>x</var>.
If <var>y</var> and <var>x</var> are both -1, then leaveok is set.  
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3027' xml:id='l2h-3027' class="function">setupterm</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>termstr, fd</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Initializes the terminal.  <var>termstr</var> is a string giving the
terminal name; if omitted, the value of the TERM environment variable
will be used.  <var>fd</var> is the file descriptor to which any
initialization sequences will be sent; if not supplied, the file
descriptor for <code>sys.stdout</code> will be used.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3028' xml:id='l2h-3028' class="function">start_color</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Must be called if the programmer wants to use colors, and before any
other color manipulation routine is called.  It is good
practice to call this routine right after <tt class="function">initscr()</tt>.

<p>
<tt class="function">start_color()</tt> initializes eight basic colors (black, red, 
green, yellow, blue, magenta, cyan, and white), and two global
variables in the <tt class="module">curses</tt> module, <tt class="constant">COLORS</tt> and
<tt class="constant">COLOR_PAIRS</tt>, containing the maximum number of colors and
color-pairs the terminal can support.  It also restores the colors on
the terminal to the values they had when the terminal was just turned
on.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3029' xml:id='l2h-3029' class="function">termattrs</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns a logical OR of all video attributes supported by the
terminal.  This information is useful when a curses program needs
complete control over the appearance of the screen.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3030' xml:id='l2h-3030' class="function">termname</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns the value of the environment variable TERM, truncated to 14
characters.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3031' xml:id='l2h-3031' class="function">tigetflag</tt></b>(</nobr></td>
  <td><var>capname</var>)</td></tr></table></dt>
<dd>
Returns the value of the Boolean capability corresponding to the
terminfo capability name <var>capname</var>.  The value <code>-1</code> is
returned if <var>capname</var> is not a Boolean capability, or <code>0</code> if
it is canceled or absent from the terminal description.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3032' xml:id='l2h-3032' class="function">tigetnum</tt></b>(</nobr></td>
  <td><var>capname</var>)</td></tr></table></dt>
<dd>
Returns the value of the numeric capability corresponding to the
terminfo capability name <var>capname</var>.  The value <code>-2</code> is
returned if <var>capname</var> is not a numeric capability, or <code>-1</code> if
it is canceled or absent from the terminal description.  
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3033' xml:id='l2h-3033' class="function">tigetstr</tt></b>(</nobr></td>
  <td><var>capname</var>)</td></tr></table></dt>
<dd>
Returns the value of the string capability corresponding to the
terminfo capability name <var>capname</var>.  <code>None</code> is returned if
<var>capname</var> is not a string capability, or is canceled or absent
from the terminal description.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3034' xml:id='l2h-3034' class="function">tparm</tt></b>(</nobr></td>
  <td><var>str</var><big>[</big><var>,...</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Instantiates the string <var>str</var> with the supplied parameters, where 
<var>str</var> should be a parameterized string obtained from the terminfo 
database.  E.g. <code>tparm(tigetstr("cup"), 5, 3)</code> could result in 
<code>'\033[6;4H'</code>, the exact result depending on terminal type.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3035' xml:id='l2h-3035' class="function">typeahead</tt></b>(</nobr></td>
  <td><var>fd</var>)</td></tr></table></dt>
<dd>
Specifies that the file descriptor <var>fd</var> be used for typeahead
checking.  If <var>fd</var> is <code>-1</code>, then no typeahead checking is
done.

<p>
The curses library does ``line-breakout optimization'' by looking for
typeahead periodically while updating the screen.  If input is found,
and it is coming from a tty, the current update is postponed until
refresh or doupdate is called again, allowing faster response to
commands typed in advance. This function allows specifying a different
file descriptor for typeahead checking.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3036' xml:id='l2h-3036' class="function">unctrl</tt></b>(</nobr></td>
  <td><var>ch</var>)</td></tr></table></dt>
<dd>
Returns a string which is a printable representation of the character
<var>ch</var>.  Control characters are displayed as a caret followed by the
character, for example as <code>^C</code>. Printing
characters are left as they are.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3037' xml:id='l2h-3037' class="function">ungetch</tt></b>(</nobr></td>
  <td><var>ch</var>)</td></tr></table></dt>
<dd>
Push <var>ch</var> so the next <tt class="method">getch()</tt> will return it.
<span class="note"><b class="label">Note:</b>
Only one <var>ch</var> can be pushed before <tt class="method">getch()</tt>
is called.</span>
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3038' xml:id='l2h-3038' class="function">ungetmouse</tt></b>(</nobr></td>
  <td><var>id, x, y, z, bstate</var>)</td></tr></table></dt>
<dd>
Push a <tt class="constant">KEY_MOUSE</tt> event onto the input queue, associating
the given state data with it.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3039' xml:id='l2h-3039' class="function">use_env</tt></b>(</nobr></td>
  <td><var>flag</var>)</td></tr></table></dt>
<dd>
If used, this function should be called before <tt class="function">initscr()</tt> or
newterm are called.  When <var>flag</var> is false, the values of
lines and columns specified in the terminfo database will be
used, even if environment variables <a class="envvar" id='l2h-3041' xml:id='l2h-3041'>LINES</a> and
<a class="envvar" id='l2h-3042' xml:id='l2h-3042'>COLUMNS</a> (used by default) are set, or if curses is running in
a window (in which case default behavior would be to use the window
size if <a class="envvar" id='l2h-3043' xml:id='l2h-3043'>LINES</a> and <a class="envvar" id='l2h-3044' xml:id='l2h-3044'>COLUMNS</a> are not set).
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3040' xml:id='l2h-3040' class="function">use_default_colors</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Allow use of default values for colors on terminals supporting this
feature. Use this to support transparency in your
application.  The default color is assigned to the color number -1.
After calling this function, 
<code>init_pair(x, curses.COLOR_RED, -1)</code> initializes, for instance,
color pair <var>x</var> to a red foreground color on the default background.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="14.7 curses  "
  href="module-curses.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="14.7 curses  "
  href="module-curses.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="14.7.2 window Objects"
  href="curses-window-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-curses.html">14.7 curses  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-curses.html">14.7 curses  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="curses-window-objects.html">14.7.2 Window Objects</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
